package com.bmadmin.controller.sms;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpSession;

import org.apache.log4j.LogManager;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.bmadmin.domain.Datagrid;
import com.bmadmin.domain.MessageDomain;
import com.bmadmin.domain.SysUsersPOJO;
import com.bmadmin.service.BeenSendService;
import com.bmadmin.util.Constants;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;


@RestController
@RequestMapping("/been")
public class BeenSendController {
	private Logger logger = LogManager.getLogger(this.getClass().getName());
	@Autowired
	BeenSendService beenSendService;
    /**
     * 获取已发送短信列表
     */
	@GetMapping("/getBeenMessage")
    public Object getBeforeMessage(HttpSession session,MessageDomain message,Integer page,Integer limit) {
    	Datagrid result = new Datagrid();
    	SysUsersPOJO user=(SysUsersPOJO) session.getAttribute(Constants.USER_INFO_SESSION);
    	Map map = new HashMap();
		map.put("qs_date", message.getQs_date());
		map.put("jz_date", message.getJz_date());
		map.put("s_nsrmc", message.getS_nsrmc());
		map.put("s_type", message.getS_type());
		PageHelper.startPage(page, limit);
		List<MessageDomain> list = beenSendService.getBeenMessageList(map);
		PageInfo pagelist = new PageInfo(list);
		result.setCode(0);
        result.setMsg("success");
        result.setData(list);
        result.setCount(pagelist.getTotal());

        return result;
    }
	
}
